/**
 * 
 */
package com.pmsco.pms.util;

import java.util.Calendar;

import com.pmsco.pms.core.domain.PmsRole;
import com.pmsco.pms.core.domain.PmsUser;

/**
 * @author Long Tran
 *
 */
public class PmsUserSession {
	private String userName;
	private String userEmailAddr;
	private String sessionId;
	private String logonRedirectUrl;
	private PmsUserRole userRole;
	private PmsRole pmsRole;
	
	/**
	 * @return the userName
	 */
	public String getUserName() {
		return userName;
	}
	
	/**
	 * @param userName the userName to set
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}
	
	/**
	 * @return the userEmailAddr
	 */
	public String getUserEmailAddr() {
		return userEmailAddr;
	}
	
	/**
	 * @param userEmailAddr the userEmailAddr to set
	 */
	public void setUserEmailAddr(String userEmailAddr) {
		this.userEmailAddr = userEmailAddr;
	}
	
	/**
	 * @return the sessionId
	 */
	public String getSessionId() {
		return sessionId;
	}

	/**
	 * @param sessionId the sessionId to set
	 */
	public void setSessionId(String sessionId) {
		this.sessionId = sessionId;
	}
	
	/**
	 * @return the logonRedirectUrl
	 */
	public String getLogonRedirectUrl() {
		return logonRedirectUrl;
	}

	/**
	 * @param logonRedirectUrl the logonRedirectUrl to set
	 */
	public void setLogonRedirectUrl(String logonRedirectUrl) {
		this.logonRedirectUrl = logonRedirectUrl;
	}

	/**
	 * @return the userRole
	 */
	public PmsUserRole getUserRole() {
		return userRole;
	}
	
	/**
	 * @param userRole the userRole to set
	 */
	public void setUserRole(PmsUserRole userRole) {
		this.userRole = userRole;
	}
	
	/**
	 * @return the pmsRole
	 */
	public PmsRole getPmsRole() {
		return pmsRole;
	}

	/**
	 * @param pmsRole the pmsRole to set
	 */
	public void setPmsRole(PmsRole pmsRole) {
		this.pmsRole = pmsRole;
	}

	public void setDetail(PmsUser logonedUser) {
		setUserName(logonedUser.getUserName());
		setUserEmailAddr(logonedUser.getEmailAddr());
		setSessionId(String.valueOf(Calendar.getInstance().getTimeInMillis()));
		setLogonRedirectUrl(logonedUser.getPmsRole().getLogonRedirectUrl());
		setUserRole(PmsUserRole.getPmsUserRole(logonedUser.getPmsRole().getRole()));
		setPmsRole(logonedUser.getPmsRole());
	}
}
